# -*- coding: utf-8 -*-
import scrapy

"""
通过post请求，发送表单数据 模拟登录
"""
class Login2Spider(scrapy.Spider):
    name = 'login2'
    allowed_domains = ['www.renren.com']
    start_urls = []

    def start_requests(self):
        url = 'http://www.renren.com/PLogin.do'
        yield scrapy.FormRequest(
            url=url,
            formdata={"email": "13179143428", "password": "hanjinda1122"},
            callback=self.parse_page)

    def parse_page(self, response):
        with open("login2.html", "w", encoding='utf8') as f:
            f.write(response.body.decode("utf-8"))
